<template>
  <div id="app">
      <transition :name="transitionName" mode="out-in">
          <router-view class="router-view" />
      </transition>
  </div>
</template>

<script>
  export default {
      data() {
          return {
              transitionName: 'slide-left'
          }
      },
      watch: {
          $route(to, from) {
              if (to.meta.index != from.meta.index) {
                  this.transitionName = 'fade' 
              } else {
                  this.transitionName = ''  
              }
          }
      }
  }
</script>

<style>
  #app {
      font-family: Avenir, Helvetica, Arial, sans-serif;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
      text-align: center;
      color: #2c3e50;
  }

  #nav {
      padding: 30px;
  }

  #nav a {
      font-weight: bold;
      color: #2c3e50;
  }

  #nav a.router-link-exact-active {
      color: #42b983;
  }

  .router-view{
      width: 100%;
      height: auto;
      position: absolute;
      top: 0;
      bottom: 0;
      margin: 0 auto;
      -webkit-overflow-scrolling: touch;
  }

  .fade-enter-active, .fade-leave-active {
    transition: opacity 0.7s;
  }
  .fade-enter, .fade-leave-to {
    opacity: 0;
  }

</style>
